package cn.com.homeyoda.aimate.aihealth.data.service;

import com.google.gson.JsonObject;

import org.json.JSONObject;

import java.util.List;

import cn.com.homeyoda.aimate.aihealth.bean.AddUserInfoBean;
import cn.com.homeyoda.aimate.aihealth.bean.AnswerAnalysisBean;
import cn.com.homeyoda.aimate.aihealth.bean.AnswerBean;
import cn.com.homeyoda.aimate.aihealth.bean.ArticleBean;
import cn.com.homeyoda.aimate.aihealth.bean.BannerBean;
import cn.com.homeyoda.aimate.aihealth.bean.BaseArticleBean;
import cn.com.homeyoda.aimate.aihealth.bean.BaseResponse;
import cn.com.homeyoda.aimate.aihealth.bean.BaseResponse2;
import cn.com.homeyoda.aimate.aihealth.bean.BindUserQrCode;
import cn.com.homeyoda.aimate.aihealth.bean.BloodPressureBean;
import cn.com.homeyoda.aimate.aihealth.bean.BmiBean;
import cn.com.homeyoda.aimate.aihealth.bean.ChronicDiseaseItemBean;
import cn.com.homeyoda.aimate.aihealth.bean.DeviceIdBean;
import cn.com.homeyoda.aimate.aihealth.bean.DeviceIsAuthBean;
import cn.com.homeyoda.aimate.aihealth.bean.ExaminationReportBean;
import cn.com.homeyoda.aimate.aihealth.bean.ExaminationReportDetailsBean;
import cn.com.homeyoda.aimate.aihealth.bean.ExaminationReportListBean;
import cn.com.homeyoda.aimate.aihealth.bean.FaceInfoBean;
import cn.com.homeyoda.aimate.aihealth.bean.FamilyMembersBean;
import cn.com.homeyoda.aimate.aihealth.bean.FeedBackDetailsBean;
import cn.com.homeyoda.aimate.aihealth.bean.FeedBackListBean;
import cn.com.homeyoda.aimate.aihealth.bean.FeedbackTypeBean;
import cn.com.homeyoda.aimate.aihealth.bean.JoinPlanBody;
import cn.com.homeyoda.aimate.aihealth.bean.UnJoinPlanBody;
import cn.com.homeyoda.aimate.aihealth.bean.QueryLinkBean;
import cn.com.homeyoda.aimate.aihealth.bean.VisualBean;
import cn.com.homeyoda.aimate.aihealth.bean.HomeReportListBean;
import cn.com.homeyoda.aimate.aihealth.bean.InspectionScheduleBean;
import cn.com.homeyoda.aimate.aihealth.bean.InspectionScheduleTypeBean;
import cn.com.homeyoda.aimate.aihealth.bean.IsShowCompleteInfoBean;
import cn.com.homeyoda.aimate.aihealth.bean.IsShowJoinFamilyBean;
import cn.com.homeyoda.aimate.aihealth.bean.KePuBannerList;
import cn.com.homeyoda.aimate.aihealth.bean.IsUpdateBean;
import cn.com.homeyoda.aimate.aihealth.bean.LevelDataBean;
import cn.com.homeyoda.aimate.aihealth.bean.LoginBean;
import cn.com.homeyoda.aimate.aihealth.bean.LoginQrCodeBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageDetailBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageListBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageTypeListBean;
import cn.com.homeyoda.aimate.aihealth.bean.MyselfPlanBean;
import cn.com.homeyoda.aimate.aihealth.bean.NavigationBean;
import cn.com.homeyoda.aimate.aihealth.bean.PersonalInfoBean;
import cn.com.homeyoda.aimate.aihealth.bean.PopularDetailBean;
import cn.com.homeyoda.aimate.aihealth.bean.PopularListBean;
import cn.com.homeyoda.aimate.aihealth.bean.PossibleFamilyMembersBean;
import cn.com.homeyoda.aimate.aihealth.bean.PromptUserListBean;
import cn.com.homeyoda.aimate.aihealth.bean.QuestionListBean;
import cn.com.homeyoda.aimate.aihealth.bean.QuestionnaireAnswerBean;
import cn.com.homeyoda.aimate.aihealth.bean.QuestionnaireNetBean;
import cn.com.homeyoda.aimate.aihealth.bean.QuestionnaireOptionBean;
import cn.com.homeyoda.aimate.aihealth.bean.QuestionnaireTopicBean;
import cn.com.homeyoda.aimate.aihealth.bean.QuizListBean;
import cn.com.homeyoda.aimate.aihealth.bean.RankingBean;
import cn.com.homeyoda.aimate.aihealth.bean.RecommendRecipeBean;
import cn.com.homeyoda.aimate.aihealth.bean.ReplenishChronicBean;
import cn.com.homeyoda.aimate.aihealth.bean.SportPlanBean;
import cn.com.homeyoda.aimate.aihealth.bean.SportPlanTitleBean;
import cn.com.homeyoda.aimate.aihealth.bean.SystemBean;
import cn.com.homeyoda.aimate.aihealth.bean.UpdateUserInfoBean;
import cn.com.homeyoda.aimate.aihealth.bean.UploadFileBean;
import cn.com.homeyoda.aimate.aihealth.bean.UploadVideoBean;
import cn.com.homeyoda.aimate.aihealth.bean.UploadVideoShareBean;
import cn.com.homeyoda.aimate.aihealth.bean.UserInfoBean;
import cn.com.homeyoda.aimate.aihealth.bean.UserIntegralBean;
import cn.com.homeyoda.aimate.aihealth.bean.UserRecordsBean;
import cn.com.homeyoda.aimate.aihealth.bean.VideoShareBean;
import cn.com.homeyoda.aimate.aihealth.bean.VideoShareListBean;
import cn.com.homeyoda.aimate.aihealth.bean.WeChatTabListBean;
import cn.com.homeyoda.aimate.aihealth.data.AddFaceBean;
import cn.com.homeyoda.aimate.aihealth.data.ApiService;
import cn.com.homeyoda.aimate.aihealth.data.ExaminationDetail;
import cn.com.homeyoda.aimate.aihealth.data.FaceIdBean;
import cn.com.homeyoda.aimate.aihealth.data.HttpDataSource;
import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * Created By 刘纯贵
 * Created Time 2020/4/29
 */
public class HttpDataSourceImpl implements HttpDataSource {
    private ApiService apiService;
    private volatile static HttpDataSourceImpl INSTANCE = null;

    public static HttpDataSourceImpl getInstance(ApiService apiService) {
        if (INSTANCE == null) {
            synchronized (HttpDataSourceImpl.class) {
                if (INSTANCE == null) {
                    INSTANCE = new HttpDataSourceImpl(apiService);
                }
            }
        }
        return INSTANCE;
    }

    public static void destroyInstance() {
        INSTANCE = null;
    }

    private HttpDataSourceImpl(ApiService apiService) {
        this.apiService = apiService;
    }

    @Override
    public Observable<BaseResponse<LoginBean>> register(String username, String password, String repassword) {
        return apiService.register(username, password, repassword);
    }

    @Override
    public Observable<BaseResponse> loginout() {
        return apiService.loginout();
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<ArticleBean>>>> getArticle(int pageNum) {
        return apiService.getArticle(pageNum);
    }

    @Override
    public Observable<BaseResponse<UserIntegralBean>> getIntegral() {
        return apiService.getIntegral();
    }

    @Override
    public Observable<BaseResponse<List<SystemBean>>> getSystemItem() {
        return apiService.getSystemItem();
    }

    @Override
    public Observable<BaseResponse<List<NavigationBean>>> getNavigationItem() {
        return apiService.getNavigationItem();
    }

    @Override
    public Observable<BaseResponse<List<SystemBean>>> getProjectList() {
        return apiService.getProjectList();
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<ArticleBean>>>> getProjectArticleList(int pageNum, int id) {
        return apiService.getProjectArticleItem(pageNum, id);
    }

    @Override
    public Observable<BaseResponse<List<WeChatTabListBean>>> getWeChatTabList() {
        return apiService.WeChatTabList();
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<ArticleBean>>>> getWechatArticleItem(int pageNum, int id) {
        return apiService.getWechatArticleItem(pageNum, id);
    }

    @Override
    public Observable<BaseResponse<List<BannerBean>>> getBanner() {
        return apiService.getBanner();
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<LevelDataBean>>>> getLevelData(int pageNum) {
        return apiService.getLevelData(pageNum);
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<RankingBean>>>> getRankingData(int pageNum) {
        return apiService.getRankingData(pageNum);
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<ArticleBean>>>> getCollectionData(int pageNum) {
        return apiService.getCollectionData(pageNum);
    }

    @Override
    public Observable<BaseResponse> collectionArticle(int id) {
        return apiService.collectionArticle(id);
    }

    @Override
    public Observable<BaseResponse> unCollectionArticle(int id) {
        return apiService.unCollectionArticle(id);
    }

    @Override
    public Observable<BaseResponse> unCollectionArticle(int id, int originId) {
        return apiService.unCollectionArticle(id, originId);
    }

    @Override
    public Observable<BaseResponse<BaseArticleBean<List<ArticleBean>>>> getSystemTypeItem(int pageNum, int id) {
        return apiService.getSystemTypeItem(pageNum, id);
    }

    @Override
    public Observable<BaseResponse2<Object>> getVideoUrl() {
        return apiService.getVideoUrl();
    }

    @Override
    public Observable<BaseResponse2<UploadVideoBean>> uploadVideo(MultipartBody.Part videoPart, RequestBody deviceIdBody) {
        return apiService.uploadVideo(videoPart, deviceIdBody);
    }

    @Override
    public Observable<ExaminationReportListBean> examinationReportList(String id, String pageSize, String pageNum, String infoId) {
        return apiService.examinationReportList(id, pageSize, pageNum, infoId);
    }

    @Override
    public Observable<ExaminationReportDetailsBean> examinationReportDetails(String id) {
        return apiService.examinationReportDetails(id);
    }

    @Override
    public Observable<BaseResponse2> deleteReport(String id) {
        return apiService.deleteReport(id);
    }

    @Override
    public Observable<InspectionScheduleBean> inspectinsSchedule(String id) {
        return apiService.inspectinsSchedule(id);
    }

    @Override
    public Observable<InspectionScheduleTypeBean> inspectinsScheduleType(String infoId, String type, String startTime, String endTime, String pageSize, String pageNum, String sort) {
        return apiService.inspectinsScheduleType(infoId, type, startTime, endTime, pageSize, pageNum, sort);
    }

    @Override
    public Observable<VisualBean> getVisualRecord(String infoId, String type, String startTime, String endTime, int pageSize, int pageNum) {
        return apiService.getVisualRecord(infoId, type, startTime, endTime, pageSize, pageNum);
    }

    @Override
    public Observable<BloodPressureBean> getBloodPressureRecord(String infoId, String type, String startTime, String endTime, int pageSize, int pageNum) {
        return apiService.getBloodPressureRecord(infoId, type, startTime, endTime, pageSize, pageNum);
    }

    @Override
    public Observable<BaseResponse2<List<QuestionnaireTopicBean>>> getQuestionnaireTopic(String id) {
        return apiService.getQuestionnaireTopic(id);
    }

    @Override
    public Observable<BaseResponse2<List<QuestionnaireOptionBean>>> getQuestionnaireOption(String id) {
        return apiService.getQuestionnaireOption(id);
    }

    @Override
    public Observable<QuestionnaireNetBean> getQuestionnaireList(int pageSize, int pageNum) {
        return apiService.getQuestionnaireList(pageSize, pageNum);
    }

    @Override
    public Observable<BaseResponse2> submitQuestionnaireAnswer(QuestionnaireAnswerBean answerBean) {
        return apiService.submitQuestionnaireAnswer(answerBean);
    }

    @Override
    public Observable<FeedbackTypeBean> getFeedBackType() {
        return apiService.getFeedBackType();
    }

    @Override
    public Observable<BaseResponse2> uploadFeedBack(JsonObject params) {
        return apiService.uploadFeedBack(params);
    }

    @Override
    public Observable<FeedBackListBean> feedBackList(String userId, String type, String describe, String pageSize, String pageNum) {
        return apiService.feedBackList(userId, type, describe, pageSize, pageNum);
    }

    @Override
    public Observable<FeedBackDetailsBean> feedBackDetails(String id) {
        return apiService.feedBackDetails(id);
    }

    @Override
    public Observable<IsShowCompleteInfoBean> isShowCompleteInfo(String faceId) {
        return apiService.isShowCompleteInfo(faceId);
    }

    @Override
    public Observable<IsShowJoinFamilyBean> isShowJoinFamily(String faceId, String deviceId, String userId) {
        return apiService.isShowJoinFamily(faceId, deviceId, userId);
    }

    @Override
    public Observable<BaseResponse2> completeInfo(JsonObject params) {
        return apiService.completeInfo(params);
    }

    @Override
    public Observable<BaseResponse2> joinFamily(JsonObject params) {
        return apiService.joinFamily(params);
    }

    @Override
    public Observable<PersonalInfoBean> getPersonalInfo(String faceId) {
        return apiService.getPersonalInfo(faceId);
    }

    @Override
    public Observable<MessageListBean> getMessageList(String userId, String pageSize, String pageNum) {
        return apiService.getMessageList(userId, pageSize, pageNum);
    }

    @Override
    public Observable<MessageDetailBean> getMessageDetail(String id) {
        return apiService.getMessageDetail(id);
    }

    @Override
    public Observable<MessageTypeListBean> getMessageTypeList() {
        return apiService.getMessageTypeList();
    }

    @Override
    public Observable<MessageTypeListBean> getQuizTypeList() {
        return apiService.getQuizTypeList();
    }

    @Override
    public Observable<QuizListBean> getQuizList(String quizType, String pageSize, String pageNum) {
        return apiService.getQuizList(quizType, pageSize, pageNum);
    }

    @Override
    public Observable<QuestionListBean> getQuestionList(String quizId) {
        return apiService.getQuestionList(quizId);
    }

    @Override
    public Observable<BaseResponse2> submitAnswer(AnswerBean answerBean) {
        return apiService.submitAnswer(answerBean);
    }

    @Override
    public Observable<UserRecordsBean> getUserRecords(String userId, String quizType, String pageSize, String pageNum) {
        return apiService.getUserRecords(userId, quizType, pageSize, pageNum);
    }

    @Override
    public Observable<AnswerAnalysisBean> getAnswerAnalysis(String quizRecordId) {
        return apiService.getAnswerAnalysis(quizRecordId);
    }

    @Override
    public Observable<PossibleFamilyMembersBean> getPossibleFamilyMembers(String userId, String deviceId) {
        return apiService.getPossibleFamilyMembers(userId, deviceId);
    }

    @Override
    public Observable<FamilyMembersBean> getFamilyMembers(String familyId) {
        return apiService.getFamilyMembers(familyId);
    }

    @Override
    public Observable<BaseResponse2> updateFamilyName(String familyId, String familyName) {
        return apiService.updateFamilyName(familyId, familyName);
    }

    @Override
    public Observable<PromptUserListBean> getPromptUserList(String familyId, String deviceId, int pageNum, int pageSize) {
        return apiService.getPromptUserList(familyId, deviceId, pageNum, pageSize);
    }

    @Override
    public Observable<BaseResponse2> addFamilyMember(String familyId, String faceId) {
        return apiService.addFamilyMember(familyId, faceId);
    }

    @Override
    public Observable<BaseResponse2> deleteFamilyMember(String familyId, String faceId) {
        return apiService.deleteFamilyMember(familyId, faceId);
    }


    @Override
    public Observable<IsUpdateBean> isUpdateMember(String id, String faceId, String userId) {
        return apiService.isUpdateMember(id, faceId, userId);
    }

    @Override
    public Observable<UserInfoBean> getUserInfo(String userInfoId) {
        return apiService.getUserInfo(userInfoId);
    }

    @Override
    public Observable<BaseResponse2> addUserInfo(AddUserInfoBean addUserInfoBean) {
        return apiService.addUserInfo(addUserInfoBean);
    }

    @Override
    public Observable<BaseResponse2> updateUserInfo(UpdateUserInfoBean updateUserInfoBean) {
        return apiService.updateUserInfo(updateUserInfoBean);
    }

    @Override
    public Observable<BaseResponse2> deleteUserInfo(JsonObject params) {
        return apiService.deleteUserInfo(params);
    }

    @Override
    public Observable<PopularListBean> getPopularList(String type, String pageNum, String pageSize) {
        return apiService.getPopularList(type, pageNum, pageSize);
    }

    @Override
    public Observable<PopularDetailBean> getPopularDetail(String id) {
        return apiService.getPopularDetail(id);
    }

    @Override
    public Observable<MessageTypeListBean> getPopularType() {
        return apiService.getPopularType();
    }

    @Override
    public Observable<BaseResponse2> readMsg(String id) {
        return apiService.readMsg(id);
    }

    @Override
    public Observable<DeviceIsAuthBean> deviceIsAuth(String deviceSn) {
        return apiService.deviceIsAuth(deviceSn);
    }

    @Override
    public Observable<BaseResponse2<LoginQrCodeBean>> getLoginQrCode() {
        return apiService.getLoginQrCode();
    }

    @Override
    public Observable<BaseResponse2> selectFamilyLoginByCode(String loginSignCode) {
        return apiService.selectFamilyLoginByCode(loginSignCode);
    }

    @Override
    public Observable<BaseResponse2<LoginBean>> login(String deviceSn, String phone) {
        return apiService.login(deviceSn, phone);
    }

    @Override
    public Observable<ReplenishChronicBean> replenishChronicList(String faceId) {
        return apiService.replenishChronicList(faceId);
    }

    @Override
    public Observable<HomeReportListBean> homeReportList(String deviceSn, String familyId, String pageNum, String pageSize) {
        return apiService.homeReportList(deviceSn, familyId, pageNum, pageSize);
    }

    @Override
    public Observable<UploadFileBean> uploadFile(RequestBody body) {
        return apiService.uploadFile(body);
    }

    @Override
    public Observable<FaceInfoBean> queryFaceInfo(String faceId, String familyId) {
        return apiService.queryFaceInfo(faceId, familyId);
    }

    @Override
    public Observable<RecommendRecipeBean> queryRecommendRecipe(String faceId) {
        return apiService.queryRecommendRecipe(faceId);
    }

    @Override
    public Observable<BmiBean> queryBmi(String faceId) {
        return apiService.queryBmi(faceId);
    }

    @Override
    public Observable<KePuBannerList> getKePuBannerList() {
        return apiService.getKePuBannerList();
    }

    @Override
    public Observable<VideoShareListBean> getVideoShareList(long id, int pageNum, int pageSize) {
        return apiService.getVideoShareList(id, pageNum, pageSize);
    }

    @Override
    public Observable<VideoShareBean> getVideoShare(long id) {
        return apiService.getVideoShare(id);
    }

    @Override
    public Observable<BaseResponse2> deleteVideoShare(long id) {
        return apiService.deleteVideoShare(id);
    }

    @Override
    public Observable<BaseResponse2> updateShareStatus(long id, int status) {
        return apiService.updateShareStatus(id, status);
    }

    @Override
    public Observable<BaseResponse2> getShareConfig(long id) {
        return apiService.getShareConfig(id);
    }

    @Override
    public Observable<BaseResponse2> uploadVideoShare(UploadVideoShareBean bean) {
        return apiService.uploadVideoShare(bean);
    }

    @Override
    public Observable<BaseResponse2> updateVideoShare(UploadVideoShareBean bean) {
        return apiService.updateVideoShare(bean);
    }

    @Override
    public Observable<ExaminationReportBean> getExaminationReportList(String userId, String infoId, int pageNum, int pageSize) {
        return apiService.getExaminationReportList(userId, infoId, pageNum, pageSize);
    }


    @Override
    public Observable<SportPlanTitleBean> sportPlanTypes() {
        return apiService.sportPlanTypes();
    }

    @Override
    public Observable<SportPlanBean> querySportPlans(String planType) {
        return apiService.querySportPlans(planType);
    }

    @Override
    public Observable<MyselfPlanBean> queryMyselfPlan(String faceId, String planId, String queryDate) {
        return apiService.queryMyselfPlan(faceId, planId, queryDate);
    }

    @Override
    public Observable<MyselfPlanBean> hasSelfPlan(String faceId) {
        return apiService.hasSelfPlan(faceId);
    }

    @Override
    public Observable<ChronicDiseaseItemBean> attentionChronicList() {
        return apiService.attentionChronicList();
    }

    @Override
    public Observable<ChronicDiseaseItemBean> attentionChronicAdd(String faceId, String dictCodes) {
        return apiService.attentionChronicAdd(faceId, dictCodes);
    }

    @Override
    public Observable<MyselfPlanBean> bindSportPlan(JoinPlanBody jsonObject) {
        return apiService.bindSportPlan(jsonObject);
    }

    @Override
    public Observable<MyselfPlanBean> unbindSportPlan(UnJoinPlanBody jsonObject) {
        return apiService.unbindSportPlan(jsonObject);
    }

    @Override
    public Observable<QueryLinkBean> queryLink(String link) {
        return apiService.queryLink(link);
    }

    @Override
    public Observable<DeviceIdBean> getDeviceId(String deviceSn) {
        return apiService.getDeviceId(deviceSn);
    }

    @Override
    public Observable<BindUserQrCode> getBindUserQrCode(String deviceSn) {
        return apiService.getBindUserQrCode(deviceSn);
    }

    @Override
    public Observable<FaceIdBean> queryFaceIdByImage(MultipartBody.Part file) {
        return apiService.queryFaceIdByImage(file);
    }

    @Override
    public Observable<AddFaceBean> uploadFaceImage(MultipartBody.Part file) {
        return apiService.uploadFaceImage(file);
    }

    @Override
    public Observable<BaseResponse2> uploadExaminationVideo(MultipartBody.Part video, RequestBody useDeviceId, RequestBody faceId, RequestBody deviceId) {
        return apiService.uploadExaminationVideo(video, useDeviceId, faceId, deviceId);
    }

    @Override
    public Observable<ExaminationDetail> fetchExaminationDetail(String examinationId) {
        return apiService.fetchExaminationDetail(examinationId);
    }
}
